package com.dk.controller;


import com.dk.bean.Result;
import com.dk.em.ResultEnum;
import com.dk.pojo.CarOrder;
import com.dk.service.CarOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 帅杰
 * @since 2021-08-11 运营商订单管理
 */
@RestController
@RequestMapping("order")
@Api
public class CarOrderController {

    @Autowired
    public CarOrderService carOrderService;

    //查询
    @GetMapping
    @ApiOperation(value = "查询方法")
    public Result toSelect(){
        List<CarOrder> carOrders=carOrderService.toSelect();
        return Result.buildResult(ResultEnum.SUCCESS).setData(carOrders);
    }
    //新增
    @PostMapping
    @ApiOperation(value = "新增")
    public Result toInsert(@RequestBody CarOrder carOrder){
        carOrderService.toInsert(carOrder);
        return Result.buildResult(ResultEnum.SUCCESS);
    }
    //修改
    @PutMapping
    @ApiOperation(value = "修改")
    public Result toUpdate(@RequestBody CarOrder carOrder){
        carOrderService.toUpdate(carOrder);
        return Result.buildResult(ResultEnum.SUCCESS);
    }
}

